// --------------------------------------------------------------------------------------------------------------------
// <copyright file="TodoItemsSettingsManager.cs" company="Roman '4ux-nbIx' Novitsky">
//   Copyright (c) Roman '4ux-nbIx' Novitsky 2009
// </copyright>
// <summary>
//   Describes and manipulates the to do items settings manager.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace SettingsManager.ComponentSettingsManagers
{
  #region Namespace Imports

  using System.Xml;

  using JetBrains.Application;
  using JetBrains.ComponentModel;
  using JetBrains.ProjectModel;
  using JetBrains.ReSharper.TodoExplorer;

  #endregion


  /// <summary>
  /// Describes and manipulates the to do items settings manager.
  /// </summary>
  internal sealed class TodoItemsSettingsManager : ResharperComponentSettingsManager
  {
    #region Constructors and Destructors

    /// <summary>
    /// Initializes a new instance of the <see cref="TodoItemsSettingsManager"/> class.
    /// </summary>
    public TodoItemsSettingsManager()
      : base("TodoManager", "Todo Items Settings")
    {
    }

    #endregion


    #region Public Methods

    /// <summary>
    /// Loads the settings.
    /// </summary>
    /// <param name="component">
    ///   The component.
    /// </param>
    /// <param name="element">
    ///   The element.
    /// </param>
    /// <param name="options"></param>
    public override void LoadSettings(IXmlExternalizableComponent component, XmlElement element, object options)
    {
      base.LoadSettings(component, element, options);

      if (SolutionManager.Instance == null || SolutionManager.Instance.CurrentSolution == null)
      {
        return;
      }

      var todoManager = TodoManager.GetInstance(SolutionManager.Instance.CurrentSolution);
      ReadLockCookie.Execute(() => todoManager.SettingsChanged(true));
    }

    #endregion
  }
}